package com.dsh.userSetting.controller;

import com.dsh.model.Result;
import com.dsh.storeManagement.entity.vo.AreaAndStoreVo;
import com.dsh.userSetting.entity.vo.IntegralGoodsVo;
import com.dsh.userSetting.entity.vo.ProjectVo;
import com.dsh.userSetting.service.IntegralGoodsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "积分商品")
@RestController
@RequestMapping("IntegralGoods")
public class IntegralGoodsController {
    @Resource
    IntegralGoodsService integralGoodsService;
    @ApiOperation(value = "查找全部商品" ,response = IntegralGoodsVo.class)
    @GetMapping("findAllIntegralGoods")
    public Result findAllIntegralGoods(){
        List<IntegralGoodsVo> allIntegralGoods = integralGoodsService.findAllIntegralGoods();
        return Result.success(allIntegralGoods,"");
    }
    @ApiOperation(value = "增加商品" ,response = IntegralGoodsVo.class)
    @PostMapping("insertIntegralGoods")
    public Result insertIntegralGoods(IntegralGoodsVo integralGoodsVo){
        int i = integralGoodsService.insertIntegralGoods(integralGoodsVo);
        return Result.success(i,"");
    }
    @ApiOperation(value = "修改商品" ,response = IntegralGoodsVo.class)
    @PostMapping("updateIntegralGoods")
    public Result updateIntegralGoods(@RequestBody IntegralGoodsVo integralGoodsVo){
        int i = integralGoodsService.updateIntegralGoods(integralGoodsVo);
        return Result.success(i,"");
    }
    @ApiOperation(value = "查看项目很其他项目的名字和id",response = ProjectVo.class)
    @GetMapping("selectProject")
    public Result selectProject(){
        List<ProjectVo> projectVos = integralGoodsService.selectProject();
        return Result.success(projectVos,"");

    }
    @ApiOperation(value = "根据id查找积分项目" ,response = ProjectVo.class)
    @GetMapping("IntegralGoodsById")
    public Result IntegralGoodsById(int id){
        IntegralGoodsVo integralGoodsVo = integralGoodsService.IntegralGoodsById(id);
        return Result.success(integralGoodsVo,"");
    }
}
